/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "cliente", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.findByClienteId", query = "SELECT c FROM Cliente c WHERE c.clienteId = :clienteId")})
public class Cliente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "clienteId")
    private Integer clienteId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "regPedClienteId")
    private List<PedidoRegistro> pedidoRegistroList;
    @JoinColumn(name = "clienteUsuarioId", referencedColumnName = "usuarioId", nullable = false)
    @ManyToOne(optional = false)
    private UsuarioPersonaRol clienteUsuarioId;
    @JoinColumn(name = "clientePersonaId", referencedColumnName = "personaId", nullable = false)
    @ManyToOne(optional = false)
    private Persona clientePersonaId;

    public Cliente() {
    }

    public Cliente(Integer clienteId) {
        this.clienteId = clienteId;
    }

    public Integer getClienteId() {
        return clienteId;
    }

    public void setClienteId(Integer clienteId) {
        this.clienteId = clienteId;
    }

    @XmlTransient
    public List<PedidoRegistro> getPedidoRegistroList() {
        return pedidoRegistroList;
    }

    public void setPedidoRegistroList(List<PedidoRegistro> pedidoRegistroList) {
        this.pedidoRegistroList = pedidoRegistroList;
    }

    public UsuarioPersonaRol getClienteUsuarioId() {
        return clienteUsuarioId;
    }

    public void setClienteUsuarioId(UsuarioPersonaRol clienteUsuarioId) {
        this.clienteUsuarioId = clienteUsuarioId;
    }

    public Persona getClientePersonaId() {
        return clientePersonaId;
    }

    public void setClientePersonaId(Persona clientePersonaId) {
        this.clientePersonaId = clientePersonaId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clienteId != null ? clienteId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cliente)) {
            return false;
        }
        Cliente other = (Cliente) object;
        if ((this.clienteId == null && other.clienteId != null) || (this.clienteId != null && !this.clienteId.equals(other.clienteId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.subway.persistencias.Cliente[ clienteId=" + clienteId + " ]";
    }
    
}
